﻿using NPOI.HSSF.UserModel;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Text;

namespace Coldairarrow.Util.Helper
{
    public class NPOIHelper
    {
        ///// <summary>
        ///// 获取字体样式
        ///// </summary>
        ///// <param name="hssfworkbook">Excel操作类</param>
        ///// <param name="fontname">字体名</param>
        ///// <param name="fontcolor">字体颜色</param>
        ///// <param name="fontsize">字体大小</param>
        ///// <returns></returns>
        //public static IFont GetFontStyle(HSSFWorkbook hssfworkbook, string fontfamily, HSSFColor fontcolor, int fontsize)
        //{
        //    IFont font1 = hssfworkbook.CreateFont();
        //    if (string.IsNullOrEmpty(fontfamily))
        //    {
        //        font1.FontName = fontfamily;
        //    }
        //    if (fontcolor != null)
        //    {
        //        font1.Color = fontcolor.GetIndex();
        //    }
        //    font1.IsItalic = true;
        //    font1.FontHeightInPoints = (short)fontsize;
        //    return font1;
        //}
        ///// <summary>
        ///// 获取单元格样式
        ///// </summary>
        ///// <param name="hssfworkbook">Excel操作类</param>
        ///// <param name="font">单元格字体</param>
        ///// <param name="fillForegroundColor">图案的颜色</param>
        ///// <param name="fillPattern">图案样式</param>
        ///// <param name="fillBackgroundColor">单元格背景</param>
        ///// <param name="ha">垂直对齐方式</param>
        ///// <param name="va">垂直对齐方式</param>
        ///// <returns></returns>
        //public static ICellStyle GetCellStyle(HSSFWorkbook hssfworkbook, IFont font, HSSFColor fillForegroundColor, FillPatternType fillPattern, HSSFColor fillBackgroundColor, HorizontalAlignment ha, VerticalAlignment va)
        //{
        //    ICellStyle cellstyle = hssfworkbook.CreateCellStyle();
        //    cellstyle.FillPattern = fillPattern;
        //    cellstyle.Alignment = ha;
        //    cellstyle.VerticalAlignment = va;
        //    if (fillForegroundColor != null)
        //    {
        //        cellstyle.FillForegroundColor = fillForegroundColor.GetIndex();
        //    }
        //    if (fillBackgroundColor != null)
        //    {
        //        cellstyle.FillBackgroundColor = fillBackgroundColor.GetIndex();
        //    }
        //    if (font != null)
        //    {
        //        cellstyle.SetFont(font);
        //    }
        //    //有边框
        //    cellstyle.BorderBottom = CellBorderType.THIN;
        //    cellstyle.BorderLeft = CellBorderType.THIN;
        //    cellstyle.BorderRight = CellBorderType.THIN;
        //    cellstyle.BorderTop = CellBorderType.THIN;
        //    return cellstyle;
        //}



    }
}
